#!/usr/bin/python3

import subprocess

## Functions
# Remove user by name
def userRemove(user):
    subprocess.call(['userdel', '-r', user])

# Add user by name and full name
def userAdd(user, fullName, path):
    subprocess.call(['useradd', '-g', '100', '-d', path, '-c', fullName, user])

## Functions End

# Read All User from passwd
names = []
f = open("/etc/passwd" , "r")
for line in f:
    records = line.split(":")
    names.append(records[0])
f.close()


# Read User Information
f = open("./users.txt" , "r")
for line in f:
    records = line.split(":")
    user = records[0]
    fullName = records[1]
    fullName = fullName.rstrip()
    path = '/home/friends/' + user
    # print(user + ":" + fullName + ":" + path)
    # Check User
    if user in names:
        userRemove(user)

f.close()